每隔固定时间抓取百度 python代码

#coding: utf-8
# www.iplaypy.com python
import sys
import urllib
import urllib2
from BeautifulSoup import BeautifulSoup
from time import sleep
while(True):
    try:
        res = urllib2.urlopen("http://www.baidu.com/")
        #baidu is encoded by gbk
        print res.read()
        sleep(3600) #per hour
    except(KeyboardInterrupt):
        print("\nbyebyebye.~")
        break
"""